package com.base.system.jpa.repository;

import com.base.system.jpa.entity.JpaUserMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserMenuRepository extends JpaRepository<JpaUserMenu, Long>, JpaSpecificationExecutor<JpaUserMenu> {
    @Modifying
    @Transactional
    @Query("delete from JpaUserMenu jm where jm.userId=:userId")
    void deleteAllByUserId(@Param("userId") Long userId);

    List<JpaUserMenu> findAllByUserId(Long userId);
}
